﻿using System;
using System.Diagnostics;

namespace Normalify
{
    public interface IDataColumn: IEquatable<IDataColumn>
    {
        Guid Id { get; }
    }

    public interface IOwnedByTable
    {
        void SetOwner(IDataTable owner);
    }

    [DebuggerDisplay("{Name}")]
    internal class DqDataColumn : IDataColumn, IOwnedByTable
    {
        private IDataTable _owner;
        private readonly Guid _id = Guid.NewGuid();

        public DqDataColumn()
        {
        }

        public string Name
        {
            get { return _owner.GetName(this); }
        }

        public bool Equals(IDataColumn other)
        {
            return Id.Equals(other.Id);
        }

        public Guid Id { get { return _id; } }
        public void SetOwner(IDataTable owner)
        {
            _owner = owner;
        }
    }
}